package com.lcy.lambda.function.柯里化;

import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
import java.util.stream.Collectors;

/**
 * 需要整合三个集合，但是集合需要分布才能拿到数据
 * @author lcy
 * @date 2025/11/5 15:56
 */
public class 柯里化2 {
    @FunctionalInterface
    interface A{
        B test(List<String> list);
    }
    public static B step1(){
        System.out.println("1.执行step1");
        List<String> list1 = new ArrayList<>();
        list1.add("gcc");
        list1.add("gyy");
        A aa = new A() {
            @Override
            public B test(List<String> a) {
                System.out.println("3.调用了A实现类的test方法");
                B b1 = b -> {
                    System.out.println("7.执行B接口的实现类");
                    C c = new C() {
                        @Override
                        public List<String> test(List<String> c) {
                            System.out.println("11.执行C接口的实现类");
                            ArrayList<String> arrayList = new ArrayList<>();
                            arrayList.addAll(a);
                            arrayList.addAll(b);
                            arrayList.addAll(c);
                            return arrayList;
                        }
                    };
                    System.out.println("8.C接口的实现类c创建成功");
                    return c;
                };
                System.out.println("4.B接口的实现类b创建成功");
                return b1;
            }
        };
        System.out.println("2.A接口的实现类a创建成功");
        B test = aa.test(list1);
        return test;
    }

    @FunctionalInterface
    interface B{
        C test(List<String> list);
    }
    public static C step2(B b){
        System.out.println("5.执行step2");
        List<String> list= new ArrayList<>();
        list.add("cwh");
        list.add("yyf");
        System.out.println("6.准备去调用B实现类的test方法");
        return b.test(list);
    }

    @FunctionalInterface
    interface C{
        List<String> test(List<String> list);
    }
    public static void step3(C c){
        System.out.println("9.执行step3");
        List<String> list = new ArrayList<>();
        list.add("zq");
        list.add("hd");
        System.out.println("10.准备去调用C实现类的test方法");
        List<String> test = c.test(list);
        test.forEach(System.out::println);

    }

    public static void main(String[] args) {
//        step3(step2(step1()));
        ArrayList<String> list = new ArrayList<>();
        list.add("gcc");
        list.add("gyy");
        list.add("cwh");
        list.add("zq");
        StringJoiner stringJoiner = new StringJoiner("-", "[", "]");
        for (String s : list) {
            stringJoiner.add(s);
        }
        System.out.println(stringJoiner);
//        List<String> collect = list.stream().collect(Collectors.toList());

        BiConsumer<List<String>, String> biConsumer = new BiConsumer<List<String>, String>() {
            @Override
            public void accept(List<String> list, String s) {
                list.add(s);
            }
        };
        Supplier<List<String>> supplier = new Supplier<List<String>>() {
            @Override
            public List<String> get() {
                return new ArrayList<>();
            }
        };
        list.stream().collect(supplier,biConsumer,List::addAll);

//        list.stream().collect(supplier,biConsumer);

        HashSet set = new HashSet();
        set.
    }
}
